import { constantRoutes, asyncRoutes } from '@/router/index.js'
const state = {
    routes: constantRoutes
}

const mutations = {
    SET_ROUTES(state, payload) {
        state.routes = [...constantRoutes, ...payload]
    }
}
const actions = {
    setRoutes(context, menus) {
        console.log(asyncRoutes);
        const newMenus = asyncRoutes.filter(item => {
            return menus.some(subitem => {
                return subitem === item.name
            })
        })
        context.commit('SET_ROUTES', newMenus)
        return newMenus
    }
}
export default {
    namespaced: true,
    state,
    mutations,
    actions
}